package com.li.controller;

import com.li.common.ModelName;
import com.li.config.AiConfig;
import com.li.config.RagAssistantFactory;
import com.li.utils.IdHandle;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ai/rag")
public class RAGController {
    @Resource
    private IdHandle idHandle;
    @Resource
    private RagAssistantFactory ragAssistantFactory;

    @RequestMapping("/chat/{id}")
    public String ragChat(@PathVariable("id") Integer id,@RequestParam(name = "message") String message)
    {
        String uid = idHandle.uidParse(id, ModelName.TEXT_EMBEDDING_V3);
        return ragAssistantFactory.createAssistant(id).chat(uid,message);
    }
}
